From: kfraser@localhost.localdomain Date: Thu, 12 Oct 2006 10:44:53 +0000 (+0100) Subject: [PRIVCMD] Fix ia64 domain creation by abstracting the singleshot mapping check. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15615^2~13 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=b73d95b84dbe1d288b816e1e4f686b4131bbc70d;p=xen.git [PRIVCMD] Fix ia64 domain creation by abstracting the singleshot mapping check. Signed-off-by: Keir Fraser --- diff --git a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c index c7f2a3632e..a17d076900 100644 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c @@ -35,6 +35,15 @@ static struct proc_dir_entry *privcmd_intf; static struct proc_dir_entry *capabilities_intf; +static int privcmd_enforce_singleshot_mapping(struct vm_area_struct *vma) +{ +#ifndef HAVE_ARCH_PRIVCMD_MMAP + if (xchg(&vma->vm_private_data, (void *)1) != NULL) + return 0; +#endif + return 1; +} + static int privcmd_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long data) { @@ -122,12 +131,10 @@ static int privcmd_ioctl(struct inode *inode, struct file *file, vma = find_vma(mm, msg.va); rc = -EINVAL; - if (!vma || (msg.va != vma->vm_start) || vma->vm_private_data) + if (!vma || (msg.va != vma->vm_start) || + !privcmd_enforce_singleshot_mapping(vma)) goto mmap_out; - /* Mapping is a one-shot operation per vma. */ - vma->vm_private_data = (void *)1; - va = vma->vm_start; for (i = 0; i < mmapcmd.num; i++) { @@ -190,14 +197,11 @@ static int privcmd_ioctl(struct inode *inode, struct file *file, if (!vma || (m.addr != vma->vm_start) || ((m.addr + (m.num<vm_end) || - vma->vm_private_data) { + !privcmd_enforce_singleshot_mapping(vma)) { up_read(&mm->mmap_sem); return -EINVAL; } - /* Mapping is a one-shot operation per vma. */ - vma->vm_private_data = (void *)1; - p = m.arr; addr = m.addr; for (i = 0; i < m.num; i++, addr += PAGE_SIZE, p++) {